//
// Created by Administrator on 2021/12/5.
//

#ifndef MARCHING_CUBES_TYPES_H
#define MARCHING_CUBES_TYPES_H

#include <vector>

using std::vector;

typedef float mc_float;

typedef unsigned int m_uint;

struct mc_vec3f {
    union {
        mc_float v[3];
        struct {
            mc_float x, y, z;
        };
    };

    inline mc_vec3f &operator+=(const mc_vec3f &r) {
        x += r.x;
        y += r.y;
        z += r.z;
        return *this;
    }

    inline mc_vec3f operator-(const mc_vec3f &r) const {
        return mc_vec3f({x - r.x, y - r.y, z - r.z});
    }

    inline mc_float &operator[](int i) {
        return v[i];
    }
};

typedef struct mc_vec3f mc_vec3f;

struct mc_vec3i {
    union {
        m_uint v[3];
        struct {
            m_uint x, y, z;
        };
    };

    inline m_uint &operator[](int i) {
        return v[i];
    }
};

typedef struct mc_vec3i mc_vec3i;

struct mc_mesh {
    vector<mc_vec3f> vertices;
    vector<mc_vec3f> normals;
    vector<m_uint> indices;
};

typedef struct mc_mesh mc_mesh;

#endif //MARCHING_CUBES_TYPES_H
